
package com.hlkj.pay.enums;

import com.hlkj.framework.common.valid.IValidEnum;
import com.hlkj.framework.common.valid.IValidStringEnum;
import com.hlkj.pay.app.common.ext.CommonExtConstant;
import com.hlkj.pay.dto.common.*;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author monk
 * @date 2023/03/23
 * @description 模板变量对象枚举
 */
public interface CommonEnum {

    @Getter
    enum MESSAGE_LOG_TYPE
    {

        BEHAVIOR_LOG(1, "行为日志"), LOGIN(2, "login日志"), LOGOUT(3, "logout日志"), CHANGE_LOG(4, "业务变更日志"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        MESSAGE_LOG_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static MESSAGE_LOG_TYPE from(Integer key) {
            MESSAGE_LOG_TYPE[] values = MESSAGE_LOG_TYPE.values();
            for (MESSAGE_LOG_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return MESSAGE_LOG_TYPE.BEHAVIOR_LOG;
        }
    }

    @Getter
    enum CHANGE_LOG_MODEL_TYPE
    {

        // 1 用户 2 角色 3 权限 4 组织
        ADMIN(1, "用户角色权限配置"), COMMON(2, "基础配置"), PAY(3, "支付配置"), MERCHANT(4, "商户"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        CHANGE_LOG_MODEL_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static CHANGE_LOG_MODEL_TYPE from(Integer key) {
            CHANGE_LOG_MODEL_TYPE[] values = CHANGE_LOG_MODEL_TYPE.values();
            for (CHANGE_LOG_MODEL_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return CHANGE_LOG_MODEL_TYPE.ADMIN;
        }
    }

    @Getter
    enum CHANGE_LOG_TYPE
    {

        // 1 用户 2 角色 3 权限 4 组织
        MESSAGE_TEMPLATE(1, "消息模板"), GEETEST(2, "极验配置"), SMS(3, "短信配置"), OCR(4, "ocr配置"), STORAGE(5, "存储配置"), PLATFORM(5, "平台配置"), DEFAULT(5, "默认配置"), COMMON_APP(6,
                "微信支付宝配置"), RSA_CONFIG(7, "rsa配置"), AGREEMENT(8, "政策协议")

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        CHANGE_LOG_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static CHANGE_LOG_TYPE from(Integer key) {
            CHANGE_LOG_TYPE[] values = CHANGE_LOG_TYPE.values();
            for (CHANGE_LOG_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return CHANGE_LOG_TYPE.MESSAGE_TEMPLATE;
        }
    }

    /**
     * 消息类型
     */
    @Getter
    @AllArgsConstructor
    enum OCR_TYPE implements IValidStringEnum
    {

        OCR_ID_FRONT(CommonExtConstant.OCR_ID_FRONT, "身份证正面"), OCR_ID_REVERSE(CommonExtConstant.OCR_ID_REVERSE, "身份证反面"), OCR_BANK_CARD(CommonExtConstant.OCR_BANK_CARD,
                "银行卡"), OCR_LICENSE(CommonExtConstant.OCR_LICENSE, "营业执照"),;

        /**
         * 编码
         */
        private String code;

        /**
         * 描述
         */
        private String desc;

        public static OCR_TYPE from(Integer key) {
            OCR_TYPE[] values = OCR_TYPE.values();
            for (OCR_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }

    }

    @Getter
    enum OssEnum implements IValidStringEnum
    {

        IMAGE("10", "image", ".png", "图片"),
        IMAGE_JPG("11", "image", ".jpg", "图片"),
        VIDEO("20", "video", ".mp4", "视频"),
        SECRET("30", "secret", ".txt", "秘钥文件"),
        FILE("40", "file", "", "文件"),
        EXCEL("40", "file", ".xlsx","文件"),
        PDF("50", "file", ".pdf", "文件"),
        ZIP("50", "file", ".zip", "文件");

        /**
         * 构造方法
         */
        private final String code;

        private final String folder;

        private final String ext;

        private final String msg;

        OssEnum(String code, String folder, String ext, String msg) {
            this.code = code;
            this.folder = folder;
            this.ext = ext;
            this.msg = msg;
        }

        @Override
        public String getDesc() {
            return "";
        }
    }

    /**
     * 消息类型
     */
    @Getter
    @AllArgsConstructor
    enum SEND_TIME_TYPE implements IValidEnum
    {

        IMMEDIATELY(1, "立即发送"), TIMING(2, "定时发送"),;

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

        public static SEND_TIME_TYPE from(Integer key) {
            SEND_TIME_TYPE[] values = SEND_TIME_TYPE.values();
            for (SEND_TIME_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return SEND_TIME_TYPE.IMMEDIATELY;
        }

    }

    /**
     * 消息类型
     */
    @Getter
    @AllArgsConstructor
    enum STATUS implements IValidEnum
    {

        WAIT_SUBMIT(1, "待提交"), SUBMITING(2, "提交中"), SUBMIT_SUCCESS(3, "提交成功"), SUBMIT_FAIL(4, "提交失败"), SEND_SUCCESS(5, "发送成功"), SEND_FAIL(6, "发送失败"),;

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

    }

    /**
     * 消息类型
     */
    @Getter
    @AllArgsConstructor
    enum TEMPLATE_TYPE implements IValidEnum
    {

        DOMESTIC_SMS(0, "国内短信", "S"), INTERNATIONAL_SMS(1, "国际/港澳台短息", "S"), EMAIL(2, "邮件", "E"), WECHAT(3, "微信", "W"), AIEMAIL(4, "ai邮件", "A"),;

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

        /**
         * 描述
         */
        private String codeValue;

        public static TEMPLATE_TYPE from(Integer key) {
            TEMPLATE_TYPE[] values = TEMPLATE_TYPE.values();
            for (TEMPLATE_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return TEMPLATE_TYPE.DOMESTIC_SMS;
        }

    }

    /**
     * 业务类型
     */
    @Getter
    @AllArgsConstructor
    enum BUSINESS_TYPE implements IValidEnum
    {

        MARKETING(1, "营销类"), NOTICE(2, "通知类"), AUTHCODE(3, "验证码");

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

        public static BUSINESS_TYPE from(Integer key) {
            BUSINESS_TYPE[] values = BUSINESS_TYPE.values();
            for (BUSINESS_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return BUSINESS_TYPE.MARKETING;
        }

    }

    /**
     * 状态
     */
    @Getter
    @AllArgsConstructor
    enum TEMPLATE_STATUS implements IValidEnum
    {

        DRAFT(0, "草稿"), ABLE(1, "上架"), UNABLE(2, "下架"),;

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

        public static TEMPLATE_STATUS from(Integer key) {
            TEMPLATE_STATUS[] values = TEMPLATE_STATUS.values();
            for (TEMPLATE_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return TEMPLATE_STATUS.DRAFT;
        }
    }

    @Getter
    enum SYS_TYPE
    {

        BUSINESS(1, "", "运营平台"), AGENT(2, "A", "代理"), MERCHANT(3, "M", "商户"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * code
         */
        private String snPrefix;

        /**
         * 错误提示
         */
        private String msg;

        SYS_TYPE(Integer code, String snPrefix, String msg) {
            this.code = code;
            this.snPrefix = snPrefix;
            this.msg = msg;
        }

        public static SYS_TYPE from(Integer key) {
            SYS_TYPE[] values = SYS_TYPE.values();
            for (SYS_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return SYS_TYPE.BUSINESS;
        }
    }

    @Getter
    enum YES_NO_TYPE implements IValidEnum
    {

        YES(1, "是"), NO(0, "否"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

        YES_NO_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static YES_NO_TYPE from(Integer key) {
            YES_NO_TYPE[] values = YES_NO_TYPE.values();
            for (YES_NO_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return YES_NO_TYPE.NO;
        }
    }

    @Getter
    enum CONFIG_TYPE
    {

        GEETEST("geetest", 1, GeetestConfig.class, CHANGE_LOG_TYPE.GEETEST, "极验"), SMS("sms", 2, SmsConfig.class, CHANGE_LOG_TYPE.SMS, "sms"), OCR("ocr", 3, OcrConfig.class,
                CHANGE_LOG_TYPE.OCR, "ocr"), STORAGE("storage", 4, StorageConfig.class, CHANGE_LOG_TYPE.STORAGE, "storage"), WEB_INFO("webInfo", 5, WebInfoConfig.class,
                        CHANGE_LOG_TYPE.PLATFORM, "web_info"), APP_INFO("appInfo", 5, AppInfoConfig.class, CHANGE_LOG_TYPE.PLATFORM, "app_info"), MERCHANT_INFO("merchantInfo", 5,
                                MerchantInfoConfig.class, CHANGE_LOG_TYPE.PLATFORM,
                                "merchant_info"), DEFAULT("default", 6, DefaultConfig.class, CHANGE_LOG_TYPE.DEFAULT, "default"), AD_PAY_TYPE("adPayType", 7, DefaultConfig.class,
                                        CHANGE_LOG_TYPE.DEFAULT, "adPayType"), RSA_CONFIG("rsaConfig", 8, RsaConfig.class, CHANGE_LOG_TYPE.RSA_CONFIG, "rsaConfig"), AGREEMENT(
                                                "agreement", 9, AgreementConfig.class, CHANGE_LOG_TYPE.AGREEMENT,
                                                "agreement"), EXCEL_TEMPLATE_PAYMENT("excelTemplate", 100, null, null, "excelTemplate_payment"), DATA_FILTER("dataFilter", 101,
                                                        null, null, "dataFilter"), BANK_BRANCH("bankBranchAppCode", 102, null, null, "bankBranchAppCode"),

        ;

        /**
         * code
         */
        private String code;

        /**
         * 类型 1 极验、2 sms、3 ocr、4 storage、5 平台设置 6 默认配置 7
         */
        private Integer type;

        private Class className;

        private CHANGE_LOG_TYPE changeLogType;

        /**
         * 错误提示
         */
        private String msg;

        CONFIG_TYPE(String code, Integer type, Class className, CHANGE_LOG_TYPE changeLogType, String msg) {
            this.code = code;
            this.type = type;
            this.className = className;
            this.changeLogType = changeLogType;
            this.msg = msg;
        }

        public static CONFIG_TYPE from(String key) {
            CONFIG_TYPE[] values = CONFIG_TYPE.values();
            for (CONFIG_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum COMMON_APP_TYPE implements IValidEnum
    {
        // 1 微信公众号 2 微信小程序 3 支付宝公众号 4 支付宝小程序

        WECHAT_PUB(1, 1, "微信公众号"),
        WECHAT_MIN(2, 1, "微信小程序"),
        ALIPAY_PUB(3, 2, "支付宝公众号"),
        ALIPAY_MIN(4, 2, "支付宝小程序"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * type
         */
        private Integer type;

        /**
         * 错误提示
         */
        private String desc;

        COMMON_APP_TYPE(Integer code, Integer type, String desc) {
            this.code = code;
            this.type = type;
            this.desc = desc;
        }

        public static COMMON_APP_TYPE from(Integer key) {
            COMMON_APP_TYPE[] values = COMMON_APP_TYPE.values();
            for (COMMON_APP_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }

        public static COMMON_APP_TYPE from(PayEnums.SCENE_PAY_TYPE scenePayType, PayEnums.PAY_TYPE payType) {
            switch (scenePayType) {
                case JSAPI:
                    switch (payType) {
                        case WECHAT:
                            return WECHAT_PUB;
                        case ALIPAY:
                            return ALIPAY_PUB;
                    }
                    break;
                case MINI_APP:
                    switch (payType) {
                        case WECHAT:
                            return WECHAT_MIN;
                        case ALIPAY:
                            return ALIPAY_MIN;
                    }
                    break;
            }
            return null;
        }
    }


    @Getter
    @AllArgsConstructor
    enum CLIENT_TYPE implements IValidEnum
    {

        WEB(0, "WEB"),
        WX_MINI(1, "WX_MINI"),
        ;

        /**
         * 编码
         */
        private Integer code;

        /**
         * 描述
         */
        private String desc;

    }

}
